package com.ruangong.GitClient.HunHePanAPI;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

import java.io.IOException;

public class Test {

    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();

        String json = "{\"q\": \"High School Musical\", \"page\": 1, \"size\": 10, \"time\": \"\", \"type\": \"\", \"exact\": true}";

        RequestBody body = RequestBody.create(json, MediaType.get("application/json; charset=utf-8"));
        Request request = new Request.Builder()
                .url("https://hunhepan.com/open/search/disk")
                .post(body)
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);

            // 处理响应的代码
            assert response.body() != null;
            System.out.println(response.body().string());
        }
    }
}
